package cn.pzx.main_module.ui.fragment

import android.os.Parcel
import android.os.Parcelable
import androidx.recyclerview.widget.GridLayoutManager
import cn.pzx.base_module.base.BaseFragment
import cn.pzx.base_module.base.BaseViewModel
import cn.pzx.main_module.R
import cn.pzx.main_module.bean.ClassifyBean
import cn.pzx.main_module.databinding.FragmentItemBinding
import cn.pzx.main_module.ui.vm.ItemFragmentVM
import com.blankj.utilcode.util.LogUtils
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder

/**
 * @author pzx
 * @description:
 * @date :3/17/21 4:52 PM
 */
class ItemFragment : BaseFragment<ItemFragmentVM, FragmentItemBinding>() {

    var classifyBeanList: MutableList<ClassifyBean>? = mutableListOf()
    var title: String = ""
    var tabId = 0


    //    private var adapter: GridRecycleAdapter? = null

    companion object {

        open fun getInstance(tabId: Int, title: String): ItemFragment? {
            val fragment = ItemFragment().apply {
                this.tabId = tabId
                this.title = title
            }
            return fragment
        }


    }


    override fun initVM() {
    }

    override fun initView() {
//        LogUtils.e("emmmm")

        vb.tvTitle.text = title

        vb.rvClassify.layoutManager = GridLayoutManager(context, 3)
        vb.rvClassify.adapter =GridRecycleAdapter(R.layout.item_fragment_classify, classifyBeanList)

    }

    override fun initClick() {
    }

    override fun initData() {


        for (j in 0 until if (tabId % 2 == 0) 6 else 10) {
            classifyBeanList!!.add(ClassifyBean(tabId * j, "二级类目$tabId-$j"))
        }


    }


    class GridRecycleAdapter(layoutResId: Int, data: MutableList<ClassifyBean>?) :
        BaseQuickAdapter<ClassifyBean, BaseViewHolder>(layoutResId, data) {
        override fun convert(holder: BaseViewHolder, item: ClassifyBean) {


        }


    }
}